package com.rxyb.rabbit.enums;

import static com.rxyb.rabbit.constants.EventConstant.*;

import org.springframework.amqp.core.ExchangeTypes;

/**
 * @author YJH
 * @version 1.0
 * @description
 * @date 2020/6/3  18:00
 */
public enum QueueEnums {

    R_LOG_RECORD(MY_LOG, "LogExchange", ExchangeTypes.DIRECT, "LogRouting");


    /**
     * 队列
     */
    private String queue;

    /**
     * 交换机
     */
    private String exchange;

    /**
     * MQ 类型
     */
    private String type;

    /**
     * 配置键
     */
    private String routing;


    QueueEnums(String queue, String exchange, String type, String routing) {
        this.queue = queue;
        this.exchange = exchange;
        this.type = type;
        this.routing = routing;
    }

    public String getQueue() {
        return this.queue;
    }

    public String getExchange() {
        return this.exchange;
    }

    public String getType() {
        return this.type;
    }

    public String getRouting() {
        return this.routing;
    }


    public static QueueEnums fromCode(String code) {
        QueueEnums[] ecs = QueueEnums.values();
        for (QueueEnums ec : ecs) {
            if (ec.getQueue().equals(code)) {
                return ec;
            }
        }
        return null;
    }

}
